#include "r2.h"
#include "CoCoA/library.H"
#include <map>
#include <vector>
using namespace CoCoA;
using namespace std;


CoCoA::GlobalManager CoCoAinitialization; // initialize a CoCoA::GlobalManager

map<size_t, SparsePolyRing> __cocoa_rings; // all CoCoA polynomial rings



//! Create a CoCoA PolyRing from with ring id myring
SparsePolyRing CreatePolyRing(size_t myring){
		map<size_t, SparsePolyRing>::iterator pos=__cocoa_rings.find(myring);
		if (pos != __cocoa_rings.end()){
			return pos->second;
		}
		else{
			pair< map< size_t, SparsePolyRing >::iterator, bool > ret = 
			__cocoa_rings.insert( make_pair(myring, NewPolyRing(RingQ(),symbols("x"))) );
			return ret.first->second;
			}
}


Polynomial::Polynomial(size_t id){
	      __data = new RingElem(CreatePolyRing(id)); //
		 
}

Polynomial::~Polynomial(){
		  delete (RingElem*)__data; // cause error
}


